<?php

namespace App\Admin\Controllers;

use App\Ebay;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class EbayController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\Ebay';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Ebay());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('SellerName', '卖家简称');

        });

        $grid->column('id', __('ID'));
        $grid->column('SellerName', __('卖家简称'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('StoreName', __('店铺ID'));
        $grid->column('Station', __('站点'));
        $grid->column('StoreState', __('店铺状态'));
        $grid->column('StoreQuota', __('店铺额度'));
        $grid->column('RegisteredEnterpriseName', __('注册企业名称'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('RegisteredPhoneNumber', __('注册手机号'));
        $grid->column('EbayEmail', __('ebay账户邮箱'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('EbayPassword', __('店铺密码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('paypal', __('收款paypal号'));
        $grid->column('MainProductCategory1', __('主要产品所属一级分类'));
        $grid->column('MainProductCategory2', __('主要产品所属二级分类'));
        $grid->column('SecondProductCategory1', __('次要产品所属一级分类'));
        $grid->column('SecondProductCategory2', __('次要产品所属二级分类'));
        $grid->column('MainSalesCountry', __('主要销售国家'));
        $grid->column('SecondSalesCountry', __('次要销售国家'));
        $grid->column('StorageLocation', __('仓储所在地'));
        $grid->column('ProportionOfInventorySales', __('海外仓存货销售占比'));
        $grid->column('AverageUnitprice', __('申请账户主管产品预估平均单价(美元)'));
        $grid->column('UK-VAT', __('UK-VAT号码'));
        $grid->column('DE-VAT', __('DE-VAT号码'));
        $grid->column('StoreGroup', __('店铺分组'));
        $grid->column('StoreNotes', __('店铺备注'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Ebay::findOrFail($id));


        $show->field('id', __('ID'));
        $show->field('SellerName', __('卖家简称'));
        $show->field('StoreName', __('店铺ID'));
        $show->field('Station', __('站点'));
        $show->field('StoreState', __('店铺状态'));
        $show->field('StoreQuota', __('店铺额度'));
        $show->field('RegisteredEnterpriseName', __('注册企业名称'));
        $show->field('RegisteredPhoneNumber', __('注册手机号'));
        $show->field('EbayEmail', __('ebay账户邮箱'));
        $show->field('EbayPassword', __('店铺密码'));
        $show->field('paypal', __('收款paypal号'));
        $show->field('MainProductCategory1', __('主要产品所属一级分类'));
        $show->field('MainProductCategory2', __('主要产品所属二级分类'));
        $show->field('SecondProductCategory1', __('次要产品所属一级分类'));
        $show->field('SecondProductCategory2', __('次要产品所属二级分类'));
        $show->field('MainSalesCountry', __('主要销售国家'));
        $show->field('SecondSalesCountry', __('次要销售国家'));
        $show->field('StorageLocation', __('仓储所在地'));
        $show->field('ProportionOfInventorySales', __('海外仓存货销售占比'));
        $show->field('AverageUnitprice', __('申请账户主管产品预估平均单价(美元)'));
        $show->field('UK-VAT', __('UK-VAT号码'));
        $show->field('DE-VAT', __('DE-VAT号码'));
        $show->field('StoreGroup', __('店铺分组'));
        $show->field('StoreNotes', __('店铺备注'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Ebay());


        $form->text('id', __('ID'));
        $form->text('SellerName', __('卖家简称'));
        $form->text('StoreName', __('店铺ID'));
        $form->text('Station', __('站点'));
        $form->text('StoreState', __('店铺状态'));
        $form->text('StoreQuota', __('店铺额度'));
        $form->text('RegisteredEnterpriseName', __('注册企业名称'));
        $form->mobile('RegisteredPhoneNumber', __('注册手机号'));
        $form->email('EbayEmail', __('ebay账户邮箱'));
        $form->password('EbayPassword', __('店铺密码'));
        $form->text('paypal', __('收款paypal号'));
        $form->text('MainProductCategory1', __('主要产品所属一级分类'));
        $form->text('MainProductCategory2', __('主要产品所属二级分类'));
        $form->text('SecondProductCategory1', __('次要产品所属一级分类'));
        $form->text('SecondProductCategory2', __('次要产品所属二级分类'));
        $form->text('MainSalesCountry', __('主要销售国家'));
        $form->text('SecondSalesCountry', __('次要销售国家'));
        $form->text('StorageLocation', __('仓储所在地'));
        $form->text('ProportionOfInventorySales', __('海外仓存货销售占比'));
        $form->text('AverageUnitprice', __('申请账户主管产品预估平均单价(美元)'));
        $form->text('UK-VAT', __('UK-VAT号码'));
        $form->text('DE-VAT', __('DE-VAT号码'));
        $form->text('StoreGroup', __('店铺分组'));
        $form->text('StoreNotes', __('店铺备注'));

        return $form;
    }
}
